// custom-tab-bar/index.js
const app = getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    selected: 0,
    color: '#999',
    selectedColor: '#424EF2',
    backgroundColor: "#FFFFFF",
    borderStyle: 'white', // 仅支持black/white
    position: 'bottom', //仅支持bottom/top
    list: [{
      "pagePath": "/pages/my-custom-tab-bar-home/index",
      "text": "首页",
      "iconPath": "/assets/images/tabbar/cefu.png",
      "selectedIconPath": "/assets/images/tabbar/cefu_active.png"
    }, {
      "pagePath": "/pages/my-custom-tab-bar-profile/index",
      "text": "我的",
      "iconPath": "/assets/images/tabbar/profile.png",
      "selectedIconPath": "/assets/images/tabbar/profile_active.png"
    }]
  },

  attached(){
    console.log(app.globalData.tabbarList);
    this.setData({
      list: app.globalData.tabbarList
    })
  },

  lifetimes: {
    // 在组件实例进入页面节点树时赋值
    attached () {
      console.log(app.globalData.tabbarList);
      this.setData({
        list: app.globalData.tabbarList
      })
    },
  },

  /**
   * 组件的方法列表
   */
  methods: {
    // 切换tab
    switchTabTap: async function(e){
      // console.log(e);
      const {jumppath, index} = e.currentTarget.dataset
      wx.switchTab({
        url: jumppath,
      })
      this.setData({
        selected: index
      })
    }
  }
})
